import { defineStore } from 'pinia'
import { reactive, ref } from 'vue'
export const useuserstore = defineStore(
  'userstore',
  () => {
    const token = ref('')
    const settoken = (newtoken) => {
      token.value = newtoken
    }
    let formdata = reactive({
      username: '',
      password: '',
      repassword: '',
      nowusername: ''
    })
    let userinfo = reactive({
      username: ['admin梁伟俊'],
      password: ['123456'],
      token: '666',
      code: -1
    })
    function clearuserinfo() {
      userinfo = reactive({
        username: ['admin梁伟俊'],
        password: ['123456'],
        token: '666',
        code: -1
      })
    }
    return {
      token,
      settoken,
      formdata,
      userinfo,
      clearuserinfo
    }
  },
  {
    persist: true //持久化处理
  }
)
